<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head th:replace="common/header::common_head"></head>
<title>公司公告</title>
<style type="text/css">
	#preview {
		display: inline-block;
		width: 100px;
		height: 100px;
		position: relative;
		background-color: #79b7e7;
		background-repeat: no-repeat;
		background-size: cover;
	}

	#imgUrl {
		width: 100%;
		height: 100%;
		opacity: 0;
		position: absolute;
		left: 0;
		top: 0;
		cursor: pointer;
		z-index: 5;
	}
</style>
<body class="hold-transition skin-blue sidebar-mini">
<div th:replace="common/LeftCommon::common_top_left"></div>
<div class="wrapper">
<div class="content-wrapper" style="min-height: 901px;">
    <div class="single-pannel">
            <section class="content-header">
                <h1>
                    公司公告
                    <small>CompanyAnnouncement</small>
                </h1>
                <ol class="breadcrumb">
                    <li><a href="/index"><i class="fa fa-dashboard"></i> 首页</a></li>
                    <li><a href="#"></a>系统设置</li>
                    <li class="active">公司公告</li>
                </ol>
            </section>
            <section class="content">
                <div class="row">
                    <div class="col-md-4" style="overflow:auto; padding: 10px; position: static">
                        <div class="box">
                            <div class="box-header">
                                <h3 class="box-title">公告</h3>
                            </div>
                            <div class="box-body table-responsive no-padding">
                                <table id="example1" class="table table-bordered table-striped" style="margin: 5px">
                                    <thead>
                                    <tr>
										<th>操作</th>
										<th>标题</th>
										<th>发布状态</th>
										<th>发布人</th>
										<th>发布时间</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr th:each="systemAnnounce,systemStat: ${systemAnnounces}">
                                        <th><a href="javascript:void(0)" th:onclick="'javascript:deleteAnnounce(\''+ ${systemAnnounce.id} + '\')'">删除</a>
                                           </th>
                                        <td><a th:text="${systemAnnounce.title}" th:href="@{'/setting/company_announcement?title=' + ${systemAnnounce.title}}"></a></td>
                                        <td th:if="${systemAnnounce.status} == true">已发布</td>
                                        <td th:if="${systemAnnounce.status} == null">发布中</td>
                                        <td th:text="${systemAnnounce.role}"></td>
                                        <td th:text="${#dates.format(systemAnnounce.createTime, 'yyyy-MM-dd  HH:mm:ss')}"></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.box-body -->
                        </div>

                    </div>

                    <div th:if="${announces} ne null" class="col-md-8" style="overflow:auto; padding: 10px; position: static">
                        <div class="box">
                            <div class="panel-heading " style="padding-bottom: 10px; ">
                                <div class="btn-pull-right">
                                    <button class="btn-normal btn-add" style="float:right">
                                        <a href="/setting/company_announcement">新增公告</a></button>
                                </div>
                                <span class="tips-text" style="float:left">&nbsp;&nbsp;公告信息</span>
                            </div>
                            <hr style=" height:2px;border:none;border-top:2px dotted #575757;">
                            <div class="panel-body">
                                <div class="">
                                    <form class="form-horizontal editor-dialog ng-invalid">
                                        <div  class="form-group ">
											<label  class="control-label col-sm-2"><span class="text-danger">* </span>标题</label>
                                            <div  th:each="announce: ${announces}" class="col-sm-8 validate_input" style="margin-top: 8px">
                                                <input th:if="${announce.title} ne null" th:value="${announce.title}" type="text" name="title" style="width: 100%;" >
                                            </div>
                                        </div>
										<div class="form-group ">
											<label class="control-label col-sm-2">内容</label>
                                            <div th:each="announce: ${announces}" class="col-sm-8 validate_input" style="margin-top: 8px">
                                                <textarea th:if="${announce.content} ne null" th:text="${announce.content}" class="form-control" name="content" style="width: 100%; min-height: 100px;" maxlength="1000"></textarea>
                                            </div>
										</div>
                                        <div th:each="announce: ${announces}" class="inputLabel" style="text-align:center;margin: 40px">
                                            <div>
                                                <p th:text="${announce.imgUrl}"></p>
                                            </div>
                                        </div>
                                    </form>
                                </div><!-- 加载完成部分end -->
                            </div>
                        </div>
                    </div>
                    <div th:if="${announces} eq null" class="col-md-8" style="overflow:auto; padding: 10px; position: static">
                        <div class="box">
                            <div class="panel-heading " style="padding-bottom: 10px; ">
                                <div class="btn-pull-right">
                                    <button class="btn-normal btn-add" style="float:right">
                                        <a href="/setting/company_announcement">新增公告</a></button>
                                </div>
                                <span class="tips-text" style="float:left">&nbsp;&nbsp;公告信息</span>
                            </div>
                            <hr style=" height:2px;border:none;border-top:2px dotted #575757;">
                            <div class="panel-body">
                                <div class="">
                                    <form class="form-horizontal editor-dialog ng-invalid" enctype="multipart/form-data" id="announce" name="announce" method="post">
                                        <div  class="form-group ">

                                            <label  class="control-label col-sm-2"><span class="text-danger">* </span>标题</label>
                                            <div  class="col-sm-8 validate_input" style="margin-top: 8px">
                                                <input  type="text" id="title" name="title" style="width: 100%;" >
                                            </div>
                                        </div>
                                        <div class="form-group ">
                                            <label class="control-label col-sm-2">内容</label>
                                            <div class="col-sm-8 validate_input" style="margin-top: 8px">
                                                <textarea class="form-control" name="content"  id="content" style="width: 100%; min-height: 100px;" maxlength="1000"></textarea>
                                            </div>
                                        </div>

                                        <div  class="form-group">
                                            <label class="control-label col-sm-3">身份</label>
                                            <div class="col-sm-8">
                                                <select name="role" id="role">
                                                    <option value="1">注册人</option>
                                                    <option value="2">管理员</option>
                                                    <option value="3">采购员</option>
                                                    <option value="4">销售员</option>
                                                    <option value="5">仓库管理员</option>
                                                    <option value="6">员工</option>
                                                    <option value="7">客户</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="inputLabel" style="text-align:center;margin: 40px">
                                            <input  type="hidden" name="imgUrl" id="imgUrl" value="" />
                                            <div class="inputLabel" style="position: absolute; margin-left: 878px; width: 122px;">
                                                <div class="plus">
                                                    <input type="file" name='file' class="file" id='file' required/>
                                                    <i class="fa fa-plus"></i>
                                                    <div class="preview">
                                                    </div>
                                                </div>
                                                <font style="display: block; text-align: center;">请上传您的头像</font>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="text-center">
                                                <input type="submit" onclick="addAnnounce()" value="保存"/>
                                            </div>
                                        </div>
                                    </form>
                                </div><!-- 加载完成部分end -->
                            </div>
                        </div>
                    </div>

                </div>
                <!-- /.row -->
            </section>

    </div>
</div>
    <footer th:replace="common/footer::common_footer"></footer>
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Create the tabs -->
        <ul class="nav nav-tabs nav-justified control-sidebar-tabs">
            <li><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
            <li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
        </ul>
        <!-- Tab panes -->
        <div class="tab-content">
            <!-- Home tab content -->
            <div class="tab-pane" id="control-sidebar-home-tab">
                <h3 class="control-sidebar-heading">Recent Activity</h3>
                <ul class="control-sidebar-menu">
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-birthday-cake bg-red"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Langdon's Birthday</h4>

                                <p>Will be 23 on April 24th</p>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-user bg-yellow"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Frodo Updated His Profile</h4>

                                <p>New phone +1(800)555-1234</p>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-envelope-o bg-light-blue"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Nora Joined Mailing List</h4>

                                <p>nora@example.com</p>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-file-code-o bg-green"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Cron Job 254 Executed</h4>

                                <p>Execution time 5 seconds</p>
                            </div>
                        </a>
                    </li>
                </ul>
                <!-- /.control-sidebar-menu -->

                <h3 class="control-sidebar-heading">Tasks Progress</h3>
                <ul class="control-sidebar-menu">
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Custom Template Design
                                <span class="label label-danger pull-right">70%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-danger" style="width: 70%"></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Update Resume
                                <span class="label label-success pull-right">95%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-success" style="width: 95%"></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Laravel Integration
                                <span class="label label-warning pull-right">50%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-warning" style="width: 50%"></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Back End Framework
                                <span class="label label-primary pull-right">68%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-primary" style="width: 68%"></div>
                            </div>
                        </a>
                    </li>
                </ul>
                <!-- /.control-sidebar-menu -->

            </div>
            <!-- /.tab-pane -->
            <!-- Stats tab content -->
            <div class="tab-pane" id="control-sidebar-stats-tab">Stats Tab Content</div>
            <!-- /.tab-pane -->
            <!-- Settings tab content -->
            <div class="tab-pane" id="control-sidebar-settings-tab">
                <form method="post">
                    <h3 class="control-sidebar-heading">General Settings</h3>

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Report panel usage
                            <input type="checkbox" class="pull-right" checked>
                        </label>

                        <p>
                            Some information about this general settings option
                        </p>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Allow mail redirect
                            <input type="checkbox" class="pull-right" checked>
                        </label>

                        <p>
                            Other sets of options are available
                        </p>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Expose author name in posts
                            <input type="checkbox" class="pull-right" checked>
                        </label>

                        <p>
                            Allow the user to show his name in blog posts
                        </p>
                    </div>
                    <!-- /.form-group -->

                    <h3 class="control-sidebar-heading">Chat Settings</h3>

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Show me as online
                            <input type="checkbox" class="pull-right" checked>
                        </label>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Turn off notifications
                            <input type="checkbox" class="pull-right">
                        </label>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Delete chat history
                            <a href="javascript:void(0)" class="text-red pull-right"><i class="fa fa-trash-o"></i></a>
                        </label>
                    </div>
                    <!-- /.form-group -->
                </form>
            </div>
            <!-- /.tab-pane -->
        </div>
    </aside>
    <div class="control-sidebar-bg"></div>
</div>
<!-- jQuery 3 -->
<script src="../../bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="../../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="../../bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="../../bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="../../bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="../../bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="../../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../../dist/js/demo.js"></script>
<!-- page script -->
<script>
    $(function () {
        $('#example1').DataTable({
            'paging'      : true,
            'lengthChange': false,
            'searching'   : false,
            'ordering'    : false,
            'info'        : false,
            'autoWidth'   : false
        })
    })
    function deleteAnnounce(announceId) {
        $.ajax({
            url:"/announce/deleteAnnounce",
            type:'POST',
            data:{
                announceId:announceId
            },
            success:function (data) {
                if (data.code == 1) {
                    window.location.href = "/announce/company_announcement";
                } else {
                    alert(data.msg);
                }
            }
        })
    }
    function addAnnounce() {
        $.ajax({
            url: "/announce/addAnnounce",
            type: "POST",
            dataType: 'json',
            data: $("#announce").serialize(),
            success: function (data) {
                if (data.code == 1) {
                    window.location.href = "/setting/company_announcement";
                    alert("增加完成")
                } else {
                    alert(data.msg);
                }
            }
        });
    }
</script>
</body>
</html>